
let channelId=getQuery("channelId");
window.onload = function () {
    findByItem(1);
}

function publish() {
    location.href = "/hairAdd.html?channelId="+channelId;
}

function findByItem(pageNO) {
    axios.get("/stick/findByItem",{
        params:{
            pageNO,
            channelId,
            title:$("title").value,
            name:$("name").value,
            startDate:$("startDate").value,
            endDate:$("endDate").value
        }
    }).then(resp =>{
        let str ="";
        let info = resp.data;
        info.records.forEach(n =>{
            str +=`<tr><td><a href="/reply.html?channelId=${n.stickId}">${n.stickTitle}</a></td>
                    <td>${n.user.name}</td><td>${n.replyNum}</td><td>${n.postDate}</td></tr>`
        });
        $("data").innerHTML = str;

        let cutStr = "";
        for (let i=1;i<=info.pages;i++){
            cutStr +=`<a style="margin-left: 10px" href="javascript:findByItem(${i})">${i}</a>`;
        }
        $("cutDiv").innerHTML = cutStr;
    })
}
